/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package models;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;


/**
 *
 * @author Yaroslav
 */
@Entity
@Table(name="questions" , catalog="", schema="")
@NamedQueries({
    @NamedQuery(name="Questions.getUserQuestion", query = "SELECT q FROM questions q WHERE q.id_user = :id_user" )
})



public class Questions extends BaseEntity implements Serializable {
     private static final long serialVersionUID = 1L;
     
     @Column(name="author")
     private Users author; 
     
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date dateTime;
    
    @OneToMany(mappedBy="id_user")
    private List<Comments> commentsList;
    
    @Column(name="text", length=500)
    private  String text;

    
    
    public Questions() {
    }
       
     public Questions(Long id) {
        this.id = id;
    } 
    
    public Questions(Users author, Date dateTime, String text) {
        this.author = author;
        this.dateTime = dateTime;
        this.text = text;
    }
    
    
    public Date getDatetime() {
        return dateTime;
    }
     
    public void setDateTime(Date dateTime) {
        this.dateTime = dateTime;
    }
    
    public Users getAuthor() {
        return author;
    }

    public void setAuthor(Users author) {
        this.author = author;
    }
     
    
    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }
    
    
    public List<Comments> getCommentsList() {
        return commentsList;
    }

    public void setCommentsList(List<Comments> commentsList) {
        this.commentsList = commentsList;
    }
    
    
    
     @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Questions)) {
            return false;
        }
        Questions other = (Questions) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "models.Questions[ id=" + id + " ]";
    }
}
